package org.mcclone.splitter;

import org.apache.commons.io.FilenameUtils;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author McClone
 */
public class FileNameGenerator {

    private AtomicInteger index;
    private String baseName;
    private String extension;
    private String concat;

    public FileNameGenerator(String fileName) {
        this(fileName, "_");
    }

    public FileNameGenerator(String fileName, String concat) {
        this.index = new AtomicInteger(0);
        this.baseName = FilenameUtils.getBaseName(fileName);
        this.extension = FilenameUtils.getExtension(fileName);
        this.concat = concat;
    }

    public String generate() {
        return baseName + concat + index.incrementAndGet() + FilenameUtils.EXTENSION_SEPARATOR + extension;
    }


}
